<?php
include('include/config.inc.php');
if(!isset($_SESSION['s_activId'.$cfgPack])
  || (isset($_SESSION['s_userType'.$cfgPack]) && isset($cfgFileNames['dailyreportmaster'][$_SESSION['s_userType'.$cfgPack]]) 
      && $cfgFileNames['dailyreportmaster'][$_SESSION['s_userType'.$cfgPack]] == 0))
{
  $_SESSION['s_urlRedirectDir'] = $_SERVER['REQUEST_URI'];
  header("Location:checkLogin.php");
}
else
{
	$msg                  = isset($_REQUEST['msg']) ? $_REQUEST['msg'] : "";
  $partySelected        = isset($_REQUEST['partyId']) ? $_REQUEST['partyId'] : '';  
  $deliveryChallanArray = array();
  $deliveryDetailArray  = array();
  $deliveryChallanCount = 0;
  $pendingDCArray       = array();
  $pendingDCDetailArray = array();
  $pendingDCCount       = 0;
  $masterDeliveryId     = 0;
  $masterDeliveryDate   = "Master Challan Created";
  ///// Select Party : Start
  $partyId       = array();
  $companyName   = array();
  
  $selectParty = "SELECT DISTINCT masterdelivery.partyId AS pid, party.companyName
                    FROM masterdelivery
                    JOIN party ON party.partyId = masterdelivery.partyId
                   ORDER BY party.companyName";
  $selectPartyResult = mysql_query($selectParty);
  $b = 0;
  while($partyRow = mysql_fetch_array($selectPartyResult))
  { 
    $partyId[$b]     = $partyRow['pid'];
    $companyName[$b] = $partyRow['companyName'];
    $b++;
  }
  ///// Select Party : End
  include("./bottom.php");
  $smarty->assign("partySelected",$partySelected);
  $smarty->assign("msg",$msg);
  $smarty->assign("deliveryChallanArray",$deliveryChallanArray);
  $smarty->assign("deliveryDetailArray",$deliveryDetailArray);
  $smarty->assign("pendingDCArray",$pendingDCArray);
  $smarty->assign("pendingDCDetailArray",$pendingDCDetailArray);
  $smarty->assign("masterDeliveryDate",$masterDeliveryDate);
  $smarty->assign("partyId",$partyId);
  $smarty->assign("companyName",$companyName);
  $smarty->display("masterDeliveryList.tpl");
}
?>